<?php

/**
* @current product.php
* @author   LiuYang <liu_yang@haibao.com>
* @date 2017年4月17日 下午3:40:20
*/
namespace haibao\classlibrary\cms\common;

class Product{
    
	public static function getCategoryParentArr(){
	    $categoryChildList = self::getCategoryChildList();
    	$categoryParentArr = array(
    	    '女装'=>array('Id'=>39,'Child'=>array(
    	        array('Id'=>39,'Name'=>'女装','ChildList'=>$categoryChildList[39]))),//女装
    	    '配饰'=>array('Id'=>4,'Child'=>array(
                array('Id'=>2,'Name'=>'鞋靴','ChildList'=>$categoryChildList[2]),
                array('Id'=>3,'Name'=>'包袋','ChildList'=>$categoryChildList[3]))),
    	    '美妆'=>array('Id'=>41,'Child'=>array(
                array('Id'=>41,'Name'=>'美妆','ChildList'=>$categoryChildList[41]),
                array('Id'=>6,'Name'=>'彩妆','ChildList'=>$categoryChildList[96]),
                array('Id'=>95,'Name'=>'护肤品','ChildList'=>$categoryChildList[95]),
                array('Id'=>133,'Name'=>'美发产品','ChildList'=>$categoryChildList[133]),
                array('Id'=>97,'Name'=>'香水','ChildList'=>$categoryChildList[97]),
                array('Id'=>138,'Name'=>'美体产品','ChildList'=>$categoryChildList[138]))),
    	    '珠宝腕表'=>array('Id'=>103,'Child'=>array(
                array('Id'=>103,'Name'=>'珠宝','ChildList'=>$categoryChildList[103]),
                array('Id'=>104,'Name'=>'腕表','ChildList'=>$categoryChildList[104]))),
    	    '男士'=>array('Id'=>1,'Child'=>array(
                array('Id'=>1,'Name'=>'男装','ChildList'=>$categoryChildList[1]),
                array('Id'=>74,'Name'=>'男鞋','ChildList'=>$categoryChildList[74]),
                array('Id'=>106,'Name'=>'男士腕表','ChildList'=>$categoryChildList[106]),
                array('Id'=>107,'Name'=>'男士护肤品','ChildList'=>$categoryChildList[107]),
                array('Id'=>108,'Name'=>'男士配饰','ChildList'=>$categoryChildList[108]),
                array('Id'=>128,'Name'=>'男士香水','ChildList'=>$categoryChildList[128]))),
    	    'LifeStyle'=>array('Id'=>42,'Child'=>array(
                array('Id'=>42,'Name'=>'家居','ChildList'=>$categoryChildList[42]),
                array('Id'=>62,'Name'=>'童装','ChildList'=>$categoryChildList[62]),
                array('Id'=>72,'Name'=>'其他','ChildList'=>$categoryChildList[72]))),
       );
    	\haibao\www\cache\Library::setSearchCache('ProductBanner',json_encode($categoryParentArr));
        return $categoryParentArr;
	}
	
    private static function getCategoryChildList(){
        $categoryCacheList = \haibao\cms\business\newproduct\Product::getCategoryList();
        $categoryChildList = array();
        foreach ($categoryCacheList as $value){
            $childList = array();
            if($value['Children']){
                foreach ($value['Children'] as $child){
                    $childList[$child['Id']] = $child['CategoryName'];
                }
            }
            $categoryChildList[$value['Id']] = $childList;
        }

        return $categoryChildList;
    }
}